package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.system.domain.WdyDeal;
import com.ruoyi.system.service.IWdyDealService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 成交记录 信息操作处理
 * 
 * @author ruoyi
 * @date 2020-01-06
 */
@Controller
@RequestMapping("/system/wdyDeal")
public class WdyDealController extends BaseController
{
    private String prefix = "system/wdyDeal";
	
	@Autowired
	private IWdyDealService wdyDealService;
	
	@RequiresPermissions("system:wdyDeal:view")
	@GetMapping()
	public String wdyDeal()
	{
	    return prefix + "/wdyDeal";
	}
	
	/**
	 * 查询成交记录列表
	 */
	@RequiresPermissions("system:wdyDeal:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WdyDeal wdyDeal)
	{
		startPage();
        List<WdyDeal> list = wdyDealService.selectWdyDealList(wdyDeal);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出成交记录列表
	 */
	@RequiresPermissions("system:wdyDeal:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WdyDeal wdyDeal)
    {
    	List<WdyDeal> list = wdyDealService.selectWdyDealList(wdyDeal);
        ExcelUtil<WdyDeal> util = new ExcelUtil<WdyDeal>(WdyDeal.class);
        return util.exportExcel(list, "wdyDeal");
    }
	
	/**
	 * 新增成交记录
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存成交记录
	 */
	@RequiresPermissions("system:wdyDeal:add")
	@Log(title = "成交记录", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(WdyDeal wdyDeal)
	{		
		return toAjax(wdyDealService.insertWdyDeal(wdyDeal));
	}

	/**
	 * 修改成交记录
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		WdyDeal wdyDeal = wdyDealService.selectWdyDealById(id);
		mmap.put("wdyDeal", wdyDeal);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存成交记录
	 */
	@RequiresPermissions("system:wdyDeal:edit")
	@Log(title = "成交记录", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(WdyDeal wdyDeal)
	{		
		return toAjax(wdyDealService.updateWdyDeal(wdyDeal));
	}
	
	/**
	 * 删除成交记录
	 */
	@RequiresPermissions("system:wdyDeal:remove")
	@Log(title = "成交记录", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(wdyDealService.deleteWdyDealByIds(ids));
	}
	
}
